package models

import "gorm.io/gorm"

type Books struct {
	gorm.Model
	Title    string   `json:"title" gorm:"type:varchar(255)"`
	Author   string   `json:"author" gorm:"type:varchar(255)"`
	Img      string   `json:"img" gorm:"type:varchar(255)"`
	Status   string   `json:"status" gorm:"type:varchar(255)"`
	CateId   uint     `json:"cateId" gorm:"type:int(10)"`
	BookType BookType `gorm:"foreignKey:CateId"`
}

type BookType struct {
	gorm.Model
	Name string `json:"name" gorm:"type:varchar(255)"`
}

type User struct {
	gorm.Model
	Username string `json:"username" gorm:"type:varchar(255)"`
	Password string `json:"password" gorm:"type:varchar(255)"`
}

type Commit struct {
	gorm.Model
	Author string `json:"author" gorm:"type:varchar(255)"`
	BookId uint   `json:"bookId" gorm:"type:int(10)"`
	UserId uint   `json:"userId" gorm:"type:int(10)"`
	Books  Books  `gorm:"foreignKey:BookId"`
	User   User   `gorm:"foreignKey:UserId"`
}

type Collect struct {
	gorm.Model
	BookId uint  `json:"bookId" gorm:"type:int(10)"`
	UserId uint  `json:"userId" gorm:"type:int(10)"`
	Books  Books `gorm:"foreignKey:BookId"`
	User   User  `gorm:"foreignKey:UserId"`
}
